package uit.minito.suggestion;

import java.util.ArrayList;

import uit.minito.timduongxebuyt.R;
import android.app.Activity;
import android.content.Context;
import android.graphics.Typeface;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class RouterInfoAdapter extends ArrayAdapter<String>{
	Activity context;
	
	private ArrayList<String> infoList;
	private ArrayList<String> titleList;
	
	public void initialize(){
		titleList = new ArrayList<String>();
		titleList.add(getContext().getResources().getString(R.string.info_MaTuyen));
		titleList.add(getContext().getResources().getString(R.string.info_TenTuyen));
		titleList.add(getContext().getResources().getString(R.string.info_TongKhoangCach));
		titleList.add(getContext().getResources().getString(R.string.info_ThoiGian));
		titleList.add(getContext().getResources().getString(R.string.info_VanToc));
		titleList.add(getContext().getResources().getString(R.string.info_ThoiGianDoi));
		titleList.add(getContext().getResources().getString(R.string.info_SoChuyenDi));
		titleList.add(getContext().getResources().getString(R.string.info_TGKhoiHanh));
		titleList.add(getContext().getResources().getString(R.string.info_DonViDamNham));
		
//		infoList = new ArrayList<String>();
//		infoList.add("RHCM001");
//		infoList.add("ben thanh");
//		infoList.add("12 km");
//		infoList.add("20 phut");
//		infoList.add("30km/h");
//		infoList.add("5ph");
//		infoList.add("30");
//		infoList.add("17h");
//		infoList.add("abc");
	}
	public RouterInfoAdapter(Context context, int textViewResourceId) {
		super(context, textViewResourceId);
		// TODO Auto-generated constructor stub
		initialize();
	}
	
	public RouterInfoAdapter(Activity context, ArrayList<String> routerInfoList){
		super(context, android.R.layout.simple_list_item_1);
		this.context=context;
		infoList = routerInfoList;
		initialize();
		
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return titleList.size()+infoList.size();
	}
	
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		View rowView = convertView;
	    if (rowView == null) {
	      LayoutInflater inflater = this.context.getLayoutInflater();
	      rowView = inflater.inflate(R.layout.info_cell, null);  
	    }
	    TextView contentView = (TextView)rowView.findViewById(R.id.infoCellTV);
	    String contentText = "";
	    if(position % 2 == 0){
	    	contentText = titleList.get(position/2);
	    	contentView.setTypeface(null, Typeface.BOLD);
	    }else{
	    	contentText = infoList.get(position/2);
	    	contentView.setTypeface(null, Typeface.ITALIC);
	    }
	    contentView.setText(contentText);
		return rowView;
	}

}
